<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
	<title>Insert title here</title>
	<script type="text/javascript" src="js/ajax.js"></script>
	<script type="text/javascript">
		function random_number() {
			var xhr = getXhr();
			// alert(xhr);
			xhr.open("get", "/ajax01/random_number.do?" + Math.random(), true);
			xhr.onreadystatechange = function () {
				if(xhr.readyState == 4 && xhr.status == 200) {
					var txt = xhr.responseText;
					$("random_number").innerHTML = txt;
				}
			};
			xhr.send(null);
		}
		
	</script>
</head>
<body style="font-size:30px;">
	<h2>Hello Ajax</h2>
	<a href="javascript:random_number();">点击产生一个随机数</a>
	<p id="random_number"></p>

</body>
</html>